﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http;
using BLL;
using Model;

namespace mood.Controllers
{
    public class TimeLineController : Controller
    {
        // GET: TimeLine
        public ActionResult Index()
        {
            TimeLineBLL bll = new TimeLineBLL();
            ReturnMessages_Page rm = bll.GetPage("", 1, 20);
            ViewBag.list = rm.rows;
            ViewBag.totalPages = rm.pages;
            return View();
        }

        public JsonResult List(int page=1)
        {
            TimeLineBLL bll = new TimeLineBLL();
            return Json(bll.GetPage("", page, 20));
        }

        public JsonResult Add(string c,string key)
        {
            if(key=="我蓝一米五")
            {
                TimeLineBLL bll = new TimeLineBLL();
                TimeLine model = new TimeLine();
                model.tl_content = c;
                model.tl_time = DateTime.Now;
                return Json(bll.Add(model));
            }
            else
            {
                ReturnMessages rm = new ReturnMessages();
                rm.code = 200;
                rm.msg = "暗号错误！";
                return Json(rm);
            }
        }

    }
}